import requests

from interface_practice.frame.apis.base_api import BaseApi

''' 企业微信的产品线业务'''
class WeWork(BaseApi):
    def __init__(self):
        self.access_token = self.get_access_token()

    def get_access_token(self):
        """
        获取access token
        """
        CORP_ID = "wwbf8507e68b65ac5f"
        CORP_SECRET = "oYnhpvWQlJl1nChZzcQ7_ufZseh_rUay-zfYmagDUvk"
        req = {
            "method": "GET",
            "url":f"https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={CORP_ID}&corpsecret={CORP_SECRET}"
        }
        # 调用自己在BaseApi 中封装的 send_api()方法
        r =self.send_api(req)

        self.access_token = r.json().get('access_token')
        print(f"access_token ==>{self.access_token}")
        return self.access_token
